Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Keep getting this error in javascript, error: column reference "id" is ambiguous

In this line SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id} I am keep getting the error column reference "id" is ambiguous, how do I solve it?

  async getAllParenFinanceOrders() {
    const programOrders = await pool.query(

      `SELECT po.*, du."displayName", du."email"
      FROM partner_orders AS po 
      LEFT JOIN ds_user AS du ON du.id = po."dsUserId" `


    );
    
    console.log("programOrders...", programOrders)

    const partnerPrograms = await Promise.all(
      programOrders.rows.map(async program => {
        const query = await pool.query(
         `SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id}`
        );
        console.log('query.rows[0]...', query.rows[0])
        return query.rows[0];
      })
    );

    return {
      programs: partnerPrograms
      
    };
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Not sure which table id you need here but you need to prefix it with one of the table ids for sure:

SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id}`
        );

Needs to be re-written as

SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE po.id = ${program.id}`
        );

OR

SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE du.id = ${program.id}`
        );

To make the error go away.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!